package com.minimalist.common.feign.client.lindi;

import com.minimalist.common.config.mybatis.bo.PageResp;
import com.minimalist.common.entity.lindi.vo.laws.LindiLawsQueryVO;
import com.minimalist.common.entity.lindi.vo.laws.LindiLawsVO;
import com.minimalist.common.feign.config.FeignConfig;
import com.minimalist.common.feign.fallback.lindi.LindiLawsFeignClientFallbackFactory;
import com.minimalist.common.response.R;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.constraints.NotNull;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 林地法规 Feign 客户端
 *
 * @author minimalist
 */
@FeignClient(name = "minimalist-lindi"
        , contextId = "lindiLawsFeignClient"
        , path = "/minimalist/lindi/laws"
        , configuration = FeignConfig.class
        , fallbackFactory = LindiLawsFeignClientFallbackFactory.class)
public interface LindiLawsFeignClient{

    /**
     * 添加法规
     *
     * @param lawsVO 法规信息
     * @return 响应结果
     */
    @PostMapping("/addLaws")
    @Operation(summary = "添加法规")
    R<?> addLaws(@RequestBody @Validated(Add.class) LindiLawsVO lawsVO);

    /**
     * 修改法规
     *
     * @param lawsVO 法规信息
     * @return 响应结果
     */
    @PutMapping("/updateLawsByLawsId")
    @Operation(summary = "修改法规")
    R<?> updateLawsByLawsId(@RequestBody @Validated(Update.class) LindiLawsVO lawsVO);

    /**
     * 删除法规
     *
     * @param lawsId 法规ID
     * @return 响应结果
     */
    @DeleteMapping("/deleteLawsByLawsId")
    @Operation(summary = "删除法规 -> 根据法规ID删除")
    R<?> deleteLawsByLawsId(
            @RequestParam("lawsId")
            @NotNull(message = "法规ID不能为空")
            @Parameter(name = "lawsId", required = true, description = "法规ID")
            Long lawsId);

    /**
     * 获取法规详情
     *
     * @param lawsId 法规ID
     * @return 法规详情
     */
    @GetMapping("/getLawsByLawsId/{lawsId}")
    @Operation(summary = "根据法规ID查询法规")
    R<LindiLawsVO> getLawsByLawsId(
            @PathVariable("lawsId")
            @NotNull(message = "法规ID不能为空")
            @Parameter(name = "lawsId", description = "法规ID", required = true)
            Long lawsId);

    /**
     * 分页查询法规列表
     *
     * @param queryVO 查询条件
     * @return 法规列表
     */
    @GetMapping("/getPageLawsList")
    @Operation(summary = "查询法规列表(分页)")
    R<PageResp<LindiLawsVO>> getPageLawsList(@RequestBody LindiLawsQueryVO queryVO);
}